﻿using Elsa.Metadata;
using System.Reflection;
using Zhp.Workflow.Models;

namespace Zhp.Workflow.Activities.DataOptions
{
    public class ApproveOptionsProvider : IActivityPropertyOptionsProvider
    {
        private readonly IApproverDataProvider _approverDataProvider;
        public ApproveOptionsProvider(IApproverDataProvider approverDataProvider)
        {
            _approverDataProvider = approverDataProvider;
        }

        public object GetOptions(PropertyInfo property)
        {
            var rv = new List<ComboSelectItem>();
            if (property.Name == "ApproveUsers")
            {
                rv = _approverDataProvider.GetApproverUsers().Result;
            }
            else if (property.Name == "ApproveRoles")
            {
                rv = _approverDataProvider.GetApproverRoles().Result;
            }
            return rv.Where(x => x.IsEnabled).ToList();
        }

    }

}
